<!DOCTYPE html>
<html lang="en">

<head>
    <title></title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <block name="style">
        <link rel="stylesheet" href="__MYCSS__/main.min.css">
    </block>
</head>
<extend name="Public/base" />
<block name="body">

    <body>
        <ol class="breadcrumb">
            <li><a href="#">财务管理</a></li>
            <li class="active">合同管理</li>
        </ol>
        <p>
            <a class="btn btn-primary" role="button" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">查询</a>
            <button type="button" class="btn btn-default" data-toggle="modal" data-target="#addModal">添加</button>
        </p>
        <div class="collapse" id="collapseExample">
            <div class="well">
                <form method="GET" action="{:U('lst')}">
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="khmc">供应商名称：</label>
                                <select class="form-control " name="khmc">
                                    <option value="">--请选择--</option>
                                    <volist name="khmc_arr" id="khmc">
                                        <option value="{$khmc}">{$khmc}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="dynbgs">对应内部公司：</label>
                                <select class="form-control " name="dynbgs">
                                    <option value="">--请选择--</option>
                                    <volist name="dynbgs_arr" id="dynbgs">
                                        <option value="{$dynbgs}">{$dynbgs}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="htbh">合同编号</label>
                                <select class="form-control " name="htbh">
                                    <option value="">--请选择--</option>
                                    <volist name="htbh_arr" id="htbh">
                                        <option value="{$htbh}">{$htbh}</option>
                                    </volist>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="year">所属年份：</label>
                                <select class="form-control father_select year_select" name="year">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group">
                                <label for="month">所属月份：</label>
                                <select class="form-control son_select month_select" name="month" disabled="disabled">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-2">
                            <div class="form-group" style="margin-top: 24px;">
                                <button type="submit" class="btn btn-success">查询</button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <div class="panel panel-default">
            <div class="panel-heading">合同管理登记表</div>

            <div class="surface_table">
                <div class="table-head">
                    <table class="table table-bordered">
                        <thead>
                            <tr class="table-h">
                                <th>合同类型</th>
                                <th>客户名称</th>
                                <th>对应公司名称</th>
                                <th>合同编号</th>
                                <th>签订日期</th>
                                <th>起始日</th>
                                <th>终止日</th>
                                <th>计费日期</th>
                                <th>数量</th>
                                <th>单价</th>
                                <th>金额</th>
                                <th>结算周期</th>
                                <th>发票种类</th>
                                <th>特别说明</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
                <div class="table-body">
                    <table class="table table-hover table-bordered">
                        <tbody>
                            <volist name="lsts" id="list">
                                <tr>
                                    <td>{$list.htlx}</td>
                                    <td>{$list.khmc}</td>
                                    <td>{$list.dynbgs}</td>
                                    <td>{$list.htbh}</td>
                                    <td>{$list.qdrq}</td>
                                    <td>{$list.qsr}</td>
                                    <td>{$list.zzr}</td>
                                    <td>{$list.jfrq}</td>
                                    <td>{$list.sl}</td>
                                    <td>{$list.dj}</td>
                                    <td>{$list.je}</td>
                                    <td>{$list.jszq}</td>
                                    <td>{$list.fpzl}</td>
                                    <td>{$list.tbsm}</td>
                                    <td>
                                        <button type="button" data-id="{$list.id}" class="btn btn-warning update_btn" data-toggle="modal" data-target="#updateModal">修改</button>
                                        <a class="btn btn-danger delete_btn" href="{:U('del',array('id'=>$list['id']))}" role="button">删除</a>
                                    </td>
                                </tr>
                            </volist>
                            <tr>
                                <td colspan="8" style="text-align: center">总计</td>
                                <td>{$sl_s}</td>
                                <td></td>
                                <td>{$je_s}</td>
                                <td colspan="4"></td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--添加面板-->
        <div class="modal fade bs-example-modal-lg" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">增加合同管理登记</h4>
                    </div>
                    <div class="modal-body">
                        <form id="khzyForm" class="public_form" action="{:U('add')}" method="post">
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addhtlx">合同类型</label>
                                        <input type="text" class="form-control" id="addhtlx" name="htlx">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addkhmc">客户/供应商名称</label>
                                        <input type="text" class="form-control" id="addkhmc" name="khmc">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="adddynbgs">对应公司名称</label>
                                        <input type="text" class="form-control" id="adddynbgs" name="dynbgs">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label for="addhtbh">合同编号</label>
                                            <input type="text" class="form-control" id="addhtbh" name="htbh">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addqdrq">签订日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addqdrq" name="qdrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addqsr">起始日</label>
                                        <input type="text" class="form-control form_date" value="" id="addqsr" name="qsr" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addzzr">终止日</label>
                                        <input type="text" class="form-control form_date" value="" id="addzzr" name="zzr" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addjfrq">计费日期</label>
                                        <input type="text" class="form-control form_date" value="" id="addjfrq" name="jfrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addsl">数量（G）</label>
                                        <input type="text" class="form-control" id="addsl" name="sl">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="adddj">单价</label>
                                        <input type="text" class="form-control" id="adddj" name="dj">
                                    </div>
                                </div>

                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addjszq">结算周期</label>
                                        <input type="text" class="form-control form_date" value="" id="addjszq" name="jszq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addfpzl">发票种类</label>
                                        <input type="text" class="form-control" id="addfpzl" name="fpzl">
                                    </div>
                                </div>
                            </div>
                            <div class="row">

                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="addtbsm">特别说明</label>
                                        <textarea id="addtbsm" class="form-control" name="tbsm" cols="30" rows="3"></textarea>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <!--修改面板-->
        <div class="modal fade bs-example-modal-lg" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog modal-lg" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">增加合同管理登记</h4>
                    </div>
                    <div class="modal-body">
                        <form id="khzyForm" class="public_form" action="{:U('edit')}" method="post">
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatehtlx">合同类型</label>
                                        <input type="text" class="form-control" id="updatehtlx" name="htlx">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatekhmc">客户/供应商名称</label>
                                        <input type="text" class="form-control" id="updatekhmc" name="khmc">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatedynbgs">对应公司名称</label>
                                        <input type="text" class="form-control" id="updatedynbgs" name="dynbgs">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <div class="form-group">
                                            <label for="updatehtbh">合同编号</label>
                                            <input type="text" class="form-control" id="updatehtbh" name="htbh">
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updateqdrq">签订日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updateqdrq" name="qdrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updateqsr">起始日</label>
                                        <input type="text" class="form-control form_date" value="" id="updateqsr" name="qsr" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatezzr">终止日</label>
                                        <input type="text" class="form-control form_date" value="" id="updatezzr" name="zzr" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatejfrq">计费日期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatejfrq" name="jfrq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatesl">数量（G）</label>
                                        <input type="text" class="form-control" id="updatesl" name="sl">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatedj">单价</label>
                                        <input type="text" class="form-control" id="updatedj" name="dj">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updategs">个数</label>
                                        <input type="text" class="form-control" id="updategs" name="gs">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatejszq">结算周期</label>
                                        <input type="text" class="form-control form_date" value="" id="updatejszq" name="jszq" data-date-format="yyyy-mm-dd" readonly>
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatefpzl">发票种类</label>
                                        <input type="text" class="form-control" id="updatefpzl" name="fpzl">
                                    </div>
                                </div>
                                <div class="col-lg-4">
                                    <div class="form-group">
                                        <label for="updatetbsm">特别说明</label>
                                        <textarea id="updatetbsm" class="form-control" name="tbsm" cols="30" rows="3"></textarea>
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" id="update_id" name="id">
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                <button type="submit" class="btn btn-primary">保存表单</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <script src="__MYJS__/main.min.js"></script>
        <script src="__MYJS__/main.js"></script>
        <script src="__MYJS__/validator.js"></script>
        <script src="__MYJS__/table.js"></script>
        <script>
            (function () {
                // 修改按钮事件
                $("table").on("click", ".update_btn", function (e) {
                    e.stopPropagation();
                    var id = $(this).attr("data-id");
                    $.ajax({
                        url: "{:U('edit')}",
                        type: 'GET', //GET
                        data: {
                            id: id
                        },
                        success: function (data) {
                            $(".public_form .form-control").each(function (index, val) {
                                var self = this;
                                for (x in data) {
                                    if ($(self).attr("name") == x) {
                                        $(self).val(data[x]);
                                    } else if (x == "kp" && $(self).attr("name") == x) {
                                        $(":radio[name='" + x + "'][value='" + data[x] +
                                            "']").prop("checked", "checked");
                                    }
                                }
                            });
                            // 重新更新日期选择器
                            $(".update_form .form_date").each(function (index, val) {
                                if ($(this).val() != "") {
                                    $(this).val(moment($(this).val(), "YYYYMMDD").format(
                                        "YYYY-MM-DD"))
                                }
                            })
                            $(".update_form .form_date").datetimepicker('update');
                        }
                    })
                    $("#update_id").val(id);
                    $('#updateModal').modal("show")
                })
                var zdytable = new window.zdytable();
            })()
        </script>

        <script>
        </script>
    </body>
</block>

</html>